package com.jpa.operation;

import java.math.BigDecimal;
import java.util.Date;

import com.jpa.entities.CtHd;
import com.jpa.entities.HoaDon;
import com.jpa.entities.KhachHang;
import com.jpa.entities.NhanVien;
import com.jpa.entities.SanPham;
import com.jpa.entities.SanPhamHoaDonPK;

public class CrudOperation {
	public NhanVien createNhanVien() {
		NhanVien nhanVien = new NhanVien();
		nhanVien.setHoTen("Nguyen van A");
		nhanVien.setMaNV("A01");
		nhanVien.setNgVL(new Date());
		nhanVien.setSoDT("09059495");
		return nhanVien;
	}

	public KhachHang createKhachHang() {
		KhachHang khachHang = new KhachHang();
		khachHang.setHoTen("Nguyen Van A");
		khachHang.setMaKH("Ma01");
		khachHang.setdChi("HCM");
		khachHang.setDoanhSo(100f);
		khachHang.setNgayDangKy(new Date());
		khachHang.setNgaySinh(new Date());
		khachHang.setSoDT("090345435");

		return khachHang;
	}

	public SanPham createSanPham() {
		SanPham sanPham = new SanPham();
		sanPham.setTenSp("Bia 333");
		sanPham.setMaSp("SP01");
		sanPham.setGia(500f);
		sanPham.setDvTinh("Lon");
		sanPham.setNuocSX("VN");

		return sanPham;
	}

	public HoaDon createHoaDon(KhachHang khachHang, NhanVien nhanVien) {
		HoaDon hoaDon = new HoaDon();
		hoaDon.setNgHD(new Date());
		hoaDon.setNhanVien(nhanVien);
		hoaDon.setKhachHang(khachHang);

		BigDecimal bigDecimal = new BigDecimal(1000);
		hoaDon.setTrGia(bigDecimal);

		return hoaDon;
	}

	public CtHd createCtHD(HoaDon hoaDon, SanPham sanPham) {
		CtHd ctHd = new CtHd();

		SanPhamHoaDonPK phamHoaDonPK = new SanPhamHoaDonPK();
		phamHoaDonPK.setMaSP(sanPham.getMaSp());
		phamHoaDonPK.setSoHD(hoaDon.getSoHD());

		ctHd.setsL(1000);
		ctHd.setSanPhamHoaDon(phamHoaDonPK);

		return ctHd;
	}

}
